package com.magic.smartcity.view.more.adapters

import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.magic.smartcity.R
import com.magic.smartcity.beans.HospitalBanner
import com.magic.smartcity.databinding.ItemHospitalBannerBinding
import com.magic.smartcity.utils.Constant
import com.youth.banner.adapter.BannerAdapter

/**
 * @description:
 * @create: Create by Magic on 2022/2/19.
 */
class HospitalBannerAdapter(data: List<HospitalBanner>) :
    BannerAdapter<HospitalBanner, HospitalBannerAdapter.ItemHolder>(data) {

    class ItemHolder(binding: ItemHospitalBannerBinding) : RecyclerView.ViewHolder(binding.root) {
        var binding = binding
    }

    private val TAG: String = "HospitalBannerAdapter"
    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ItemHolder {
        val inflate = DataBindingUtil.inflate<ItemHospitalBannerBinding>(
            LayoutInflater.from(parent?.context),
            R.layout.item_hospital_banner,
            parent,
            false
        )
        return ItemHolder(inflate)
    }

    override fun onBindView(holder: ItemHolder?, data: HospitalBanner?, position: Int, size: Int) {
        Log.d(TAG,size.toString())
        Glide.with(holder?.binding?.root!!).load(Constant.Service_IP + data?.imgUrl)
            .error(R.color.gray).into(holder.binding.image)
        holder.binding.image.setOnClickListener {

        }
    }
}